var gamedata={
    "basicMaterials":{
        "unlock":"true","unlocked":false,
        "title":"基础资源",
        "material":{
            "food":{
                "name":"食物",
                "info":"一切生灵的本源",
                "unlock":"true","unlocked":false,
                "count":0,"limit":5,"speed":0,"bounce":1,
                "options":[
                    {
                        "title":"采集食物","info":"",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"","check":"true",
                            "button":"采集 1 食物",
                            "onclick":"let temp=gamedata.basicMaterials.material.food;temp.count=Math.min(temp.limit,temp.count+1)",
                        }]
                    },{
                        "title":"扩充仓库","info":"",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"${process(gamedata.basicMaterials.material.food.limit)} 食物",
                            "check":"let temp=gamedata.basicMaterials.material.food;temp.count==temp.limit",
                            "button":"扩充仓库至 2 倍",
                            "onclick":"let temp=gamedata.basicMaterials.material.food;temp.limit*=2,temp.count=0",
                        }]
                    },{
                        "title":"小型植物盆栽","info":"每秒提供 1 个食物",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"${process(self.count*5+10)} 食物 & ${process(self.count*3+5)} 石头",
                            "check":`
                                let temp=gamedata.basicMaterials.material;let self=temp.food.options[2];
                                temp.food.count>=self.count*5+10&&temp.stone.count>=self.count*3+5&&self.count<self.limit`,
                            "button":"种植 1 个小型植物盆栽",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material;let self=temp.food.options[2];
                                temp.food.count-=self.count*5+10,temp.stone.count-=self.count*3+5,temp.food.speed+=0.04,self.count++`,
                        }],
                        "count":0,"limit":5,
                    },
                ]
            },
            "stone":{
                "name":"石头",
                "info":"随处可见的石头",
                "unlock":"true","unlocked":false,
                "count":0,"limit":5,"speed":0,"bounce":1,
                "options":[
                    {
                        "title":"采集石头","info":"",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"","check":"true",
                            "button":"采集 1 石头",
                            "onclick":"let temp=gamedata.basicMaterials.material.stone;temp.count=Math.min(temp.limit,temp.count+1)",
                        }],
                    },{
                        "title":"扩充仓库","info":"",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"${process(gamedata.basicMaterials.material.stone.limit)} 石头",
                            "check":"let temp=gamedata.basicMaterials.material.stone;temp.count==temp.limit",
                            "button":"扩充仓库至 2 倍",
                            "onclick":"let temp=gamedata.basicMaterials.material.stone;temp.limit*=2,temp.count=0",
                        }],
                    },{
                        "title":"小型采石机器","info":"每秒提供 1 个石头",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"${process(self.count*5+10)} 石头 & ${process(self.count*3+5)} 木头",
                            "check":`
                                let temp=gamedata.basicMaterials.material;let self=temp.stone.options[2];
                                temp.stone.count>=self.count*5+10&&temp.wood.count>=self.count*3+5&&self.count<self.limit`,
                            "button":"制造 1 个小型采石机器",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material;let self=temp.stone.options[2];
                                temp.stone.count-=self.count*5+10,temp.wood.count-=self.count*3+5,temp.stone.speed+=0.04,self.count++`,
                        }],
                        "count":0,"limit":5,
                    },
                ]
            },
            "wood":{
                "name":"木头",
                "info":"宝贵的森林资源",
                "unlock":"true","unlocked":false,
                "count":0,"limit":5,"speed":0,"bounce":1,
                "options":[
                    {
                        "title":"采集木头","info":"",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"","check":"true",
                            "button":"采集 1 木头",
                            "onclick":"let temp=gamedata.basicMaterials.material.wood;temp.count=Math.min(temp.limit,temp.count+1)",
                        }],
                    },{
                        "title":"扩充仓库","info":"",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"${process(gamedata.basicMaterials.material.wood.limit)} 木头",
                            "check":"let temp=gamedata.basicMaterials.material.wood;temp.count==temp.limit",
                            "button":"扩充仓库至 2 倍",
                            "onclick":"let temp=gamedata.basicMaterials.material.wood;temp.limit*=2,temp.count=0",
                        }],
                    },{
                        "title":"小型伐木机器","info":"每秒提供 1 个木头",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"${process(self.count*5+10)} 木头 & ${process(self.count*3+5)} 食物",
                            "check":`
                                let temp=gamedata.basicMaterials.material;let self=temp.wood.options[2];
                                temp.wood.count>=self.count*5+10&&temp.food.count>=self.count*3+5&&self.count<self.limit`,
                            "button":"制造 1 个小型伐木机器",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material;let self=temp.wood.options[2];
                                temp.wood.count-=self.count*5+10,temp.food.count-=self.count*3+5,temp.wood.speed+=0.04,self.count++`,
                        }],
                        "count":0,"limit":5,
                    },
                ]
            }
        },
    },
    "societyResources":{
        "unlock":"let temp=gamedata.basicMaterials.material;temp.wood.count>=30&&temp.stone.count>=30&&temp.food.count>=30",
        "unlocked":false,
        "title":"社会资源",
        "material":{
            "house":{
                "name":"居住环境",
                "info":"良好的居住环境是发展的根本",
                "unlock":"true","unlocked":false,
                "options":[
                    {
                        "title":"仓库","info":"每个仓库提供 3 个存放小型植物盆栽、小型采石机器以及小型伐木机器的空位",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"${process(self.count*15+40)} 木头 & ${process(self.count*13+60)} 石头 & ${process(self.count*14+10)} 食物",
                            "check":`
                                let temp=gamedata.basicMaterials.material,self=gamedata.societyResources.material.house.options[0];
                                temp.wood.count>=self.count*15+40&&temp.stone.count>=self.count*13+60&&temp.food.count>=self.count*14+10&&self.count<self.limit`,
                            "button":"建造 1 个仓库",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material,self=gamedata.societyResources.material.house.options[0];
                                temp.wood.count-=self.count*15+40,temp.stone.count-=self.count*13+60,temp.food.count-=self.count*14+10,self.count++
                                temp.food.options[2].limit+=3,temp.stone.options[2].limit+=3,temp.wood.options[2].limit+=3`,
                        }],
                        "count":0,"limit":5,
                    },{
                        "title":"小屋","info":"每个小屋可提供 2 个教徒居住",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"${process(self.count*26+60)} 木头 & ${process(self.count*20+100)} 石头 & ${process(self.count*24+50)} 食物",
                            "check":`
                                let temp=gamedata.basicMaterials.material,self=gamedata.societyResources.material.house.options[1];
                                temp.wood.count>=self.count*26+60&&temp.stone.count>=self.count*20+100&&temp.food.count>=self.count*24+50&&self.count<self.limit`,
                            "button":"建造 1 个小屋",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material,self=gamedata.societyResources.material.house.options[1];
                                temp.wood.count-=self.count*26+60,temp.stone.count-=self.count*20+100,temp.food.count-=self.count*24+50,self.count++
                                gamedata.peopleResources.material.people.limit+=2,gamedata.peopleResources.material.people.count+=2`,
                        }],
                        "count":0,"limit":5,
                    }
                ],
            },
            "science":{
                "name":"科技",
                "info":"科技使人进步",
                "unlock":"true","unlocked":false,
                "count":0,"limit":10,"speed":0,"bounce":1,
                "options":[]
            },
        },
    },
    "peopleResources":{
        "unlock":"gamedata.societyResources.material.house.options[1].count>0",
        "unlocked":false,
        "title":"人口管理",
        "material":{
            "people":{
                "name":"教徒",
                "info":"老教的发展由此开始……",
                "unlock":"true","unlocked":false,
                "count":0,"limit":0,
                "options":[
                    {
                        "title":"农民","info":"每个农民额外提供 7% 的食物增长速度",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"1 空闲教徒 & ${process(self.count*70+50)} 食物",
                            "check":`gamedata.peopleResources.material.people.count>0&&gamedata.basicMaterials.material.food.count>=gamedata.peopleResources.material.people.options[0].count*125+50`,
                            "button":"雇佣 1 个农民",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material.food,self=gamedata.peopleResources.material.people;
                                gamedata.basicMaterials.material.food.count-=gamedata.peopleResources.material.people.options[0].count*70+50
                                temp.bounce+=0.07,self.count--,self.options[0].count++;`,
                        },{
                            "cost":"1 农民","check":`gamedata.peopleResources.material.people.options[0].count>0`,
                            "button":"解雇 1 个农民",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material.food,self=gamedata.peopleResources.material.people;
                                temp.bounce-=0.07,self.count++,self.options[0].count--;`,
                        }],
                        "count":0,"limit":Infinity,
                    },{
                        "title":"矿工","info":"每个矿工额外提供 3% 的石头增长速度",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"1 空闲教徒 & ${process(self.count*70+50)} 食物",
                            "check":`gamedata.peopleResources.material.people.count>0&&gamedata.basicMaterials.material.food.count>=gamedata.peopleResources.material.people.options[0].count*125+50`,
                            "button":"雇佣 1 个矿工",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material.stone,self=gamedata.peopleResources.material.people;
                                gamedata.basicMaterials.material.food.count-=gamedata.peopleResources.material.people.options[1].count*70+50
                                temp.bounce+=0.03,self.count--,self.options[1].count++;`,
                        },{
                            "cost":"1 矿工","check":`gamedata.peopleResources.material.people.options[1].count>0`,
                            "button":"解雇 1 个矿工",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material.stone,self=gamedata.peopleResources.material.people;
                                temp.bounce-=0.03,self.count++,self.options[1].count--;`,
                        }],
                        "count":0,"limit":Infinity,
                    },{
                        "title":"伐木工","info":"每个伐木工额外提供 3% 的木头增长速度",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"1 空闲教徒 & ${process(self.count*70+50)} 食物",
                            "check":`gamedata.peopleResources.material.people.count>0&&gamedata.basicMaterials.material.food.count>=gamedata.peopleResources.material.people.options[0].count*125+50`,
                            "button":"雇佣 1 个伐木工",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material.wood,self=gamedata.peopleResources.material.people;
                                gamedata.basicMaterials.material.food.count-=gamedata.peopleResources.material.people.options[2].count*70+50
                                temp.bounce+=0.03,self.count--,self.options[2].count++;`,
                        },{
                            "cost":"1 伐木工","check":`gamedata.peopleResources.material.people.options[2].count>0`,
                            "button":"解雇 1 个伐木工",
                            "onclick":`
                                let temp=gamedata.basicMaterials.material.wood,self=gamedata.peopleResources.material.people;
                                temp.bounce-=0.03,self.count++,self.options[2].count--;`,
                        }],
                        "count":0,"limit":Infinity,
                    },{
                        "title":"博士","info":"每个博士额外提供 0.1 的科技增长速度",
                        "unlock":"true","unlocked":false,
                        "buttons":[{
                            "cost":"1 空闲教徒 & ${process(self.count*125+50)} 食物",
                            "check":`gamedata.peopleResources.material.people.count>0&&gamedata.basicMaterials.material.food.count>=gamedata.peopleResources.material.people.options[0].count*125+50`,
                            "button":"雇佣 1 个博士",
                            "onclick":`
                                let self=gamedata.peopleResources.material.people,temp=gamedata.societyResources.material.science;
                                gamedata.basicMaterials.material.food.count-=gamedata.peopleResources.material.people.options[3].count*125+50
                                temp.speed+=0.1/25,self.count--,self.options[3].count++;`,
                        },{
                            "cost":"1 博士","check":`gamedata.peopleResources.material.people.options[3].count>0`,
                            "button":"解雇 1 个博士",
                            "onclick":`
                                let self=gamedata.peopleResources.material.people,temp=gamedata.societyResources.material.science;
                                temp.bounce-=0.1/25,self.count++,self.options[3].count--;`,
                        }],
                        "count":0,"limit":Infinity,
                    },
                ],
            }
        },
    }
};

/*

To do list : 

1. Update the data of societyResources.
2. Update the data of peopleResources.

*/